Implement cfg-based target-specific dependencies
authorAlex Crichton <alex@alexcrichton.com>
Tue, 26 Jan 2016 00:54:10 +0000 (16:54 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 14 Feb 2016 19:20:47 +0000 (11:20 -0800)
commitf5d786e05600720ba4671caf5b598624103c8f72
tree32b75c2a00fe2a78b09b5a069617a6acdcd8f416
parent3afc341ab2a6efe69eea1ecc4a9312130e20f54f
Implement cfg-based target-specific dependencies

This commit is an implementation of [RFC 1361][rfc] which is an extension of
Cargo's `target` section in `Cargo.toml` to allow the use of `#[cfg]`-like
expressions for target-specific dependencies. Now that the compiler has been
extended with `--print cfg` each invocation of Cargo will scrape this output and
learn about the relevant `#[cfg]` directives in play for the target being
compiled. Cargo will then use these directives to decide whether a dependency
should be activated or not.

This should allow definition of dependencies along the lines of:

    [target.'cfg(unix)'.dependencies]
    [target.'cfg(target_os = "linux")'.dependencies]
    [target.'cfg(windows)'.dependencies]

Which is much more ergonomic and robust than listing all the triples out!
src/cargo/core/dependency.rs
src/cargo/ops/cargo_rustc/context.rs
src/cargo/ops/registry.rs
src/cargo/sources/registry.rs
src/cargo/util/cfg.rs [new file with mode: 0644]
src/cargo/util/mod.rs
src/cargo/util/toml.rs
src/doc/manifest.md
tests/support/registry.rs
tests/test_cargo_cfg.rs [new file with mode: 0644]
tests/tests.rs